﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HRDexCapstoneProject.Functions.Messege
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string annsearch = (string)(Session["msgSearch"]);
            if (annsearch != null)
            {
                //AnnouncementBullitin.SelectCommand = "SELECT * FROM formAnnouncement WHERE (Subject LIKE '" + annsearch + "%')";
                formMessege.SelectCommand = "SELECT     formMessegeSender.MessageID, formMessegeSender.Subject, formMessegeSender.DateTime, formMessegeSender.AttachmentName, " +
                      "formMessegeSender.Parent, formEmployees.LastName + ', ' + formEmployees.FirstName AS fulname, catMessege.catMessegeName" +  
                      "FROM         formMessegeSender INNER JOIN" +
                      "formEmployees ON formMessegeSender.EmployeeID = formEmployees.EmployeeID INNER JOIN" +
                      "catMessege ON formMessegeSender.catMessegeID = catMessege.catMessegeID" +
                      "WHERE     (formMessegeSender.fromEmpID = " + SessionID() + ") AND (formMessegeSender.Subject = " + annsearch +")";
            }
        }
        string SessionID()
        {
            return Session["EmployeeNo"].ToString();
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["messageID"] = GridView1.SelectedDataKey.Value.ToString();
            Server.Transfer("~/Functions/Messege/Add.aspx");
            //Response.Redirect("~/Function/Messege/Add.aspx");
        }
        public string msgid()
        {
            return GridView1.SelectedValue.ToString();
        }

       
    }
}